﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using nPress.Core.Entities;
using FluentNHibernate.Mapping;

namespace nPress.Core.Mapping
{
    public class CommentMap : MapBase<Comment>
    {
        #region SQL

        /*
         CREATE TABLE comments (
          comment_ID bigint(20) unsigned NOT NULL auto_increment,
          comment_post_ID bigint(20) unsigned NOT NULL default '0',
          comment_author tinytext NOT NULL,
          comment_author_email varchar(100) NOT NULL default '',
          comment_author_url varchar(200) NOT NULL default '',
          comment_author_IP varchar(100) NOT NULL default '',
          comment_date datetime NOT NULL default '0000-00-00 00:00:00',
          comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
          comment_content text NOT NULL,
          comment_karma int(11) NOT NULL default '0',
          comment_approved varchar(20) NOT NULL default '1',
          comment_agent varchar(255) NOT NULL default '',
          comment_type varchar(20) NOT NULL default '',
          comment_parent bigint(20) unsigned NOT NULL default '0',
          user_id bigint(20) unsigned NOT NULL default '0',
          PRIMARY KEY  (comment_ID),
          KEY comment_approved (comment_approved),
          KEY comment_post_ID (comment_post_ID),
          KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
          KEY comment_date_gmt (comment_date_gmt)
        )
         */
        #endregion
        public CommentMap() : base("comments")
        {
            Id(x => x.Id,"comment_ID");
            References(x => x.Post, "comment_post_ID").Not.Nullable();
            Map(x => x.Author, "comment_author").WithLengthOf(255).Not.Nullable();
            Map(x => x.AuthorEmail, "comment_author_email").WithLengthOf(100).Not.Nullable();
            Map(x => x.AuthorUrl, "comment_author_url").WithLengthOf(200).Not.Nullable();
            Map(x => x.AuthorIP, "comment_author_IP").WithLengthOf(100).Not.Nullable();
            Map(x => x.Date, "comment_date").Not.Nullable();
            Map(x => x.DateGMT, "comment_date_gmt").Not.Nullable();
            Map(x => x.Content, "comment_content").Not.Nullable();
            Map(x => x.Karma, "comment_karma").Not.Nullable();
            Map(x => x.Approved, "comment_approved").WithLengthOf(20).Not.Nullable();
            Map(x => x.Agent, "comment_agent").WithLengthOf(255).Not.Nullable();
            Map(x => x.Type, "comment_type").WithLengthOf(20).Not.Nullable();
            References(x => x.Parent, "comment_parent");
            References(x => x.User, "user_id");
            


            
            
           
        }
    }
}
